package com.remote.server.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.smartcar.client.servce.ClientServiceFeigin;
import com.smartcar.common.domain.User;
import com.smartcar.common.domain.response.OrderResponse;
import com.remote.common.OrderReceiving;
import com.remote.server.mapper.DispatchMapper;
import com.remote.server.service.DispatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DispatchServiceImpl implements DispatchService {

    @Autowired
    private DispatchMapper dispatchMapper;

    @Autowired
    private RedisTemplate<String,String> redisTemplate;




    /**
     * 查询司机
     * @param
     * @return
     */
    @Override
    public List<User> missedOrder() {
        List<User> list = dispatchMapper.missedOrder();
//        redisTemplate.opsForValue().set("list1",JSONObject.toJSONString(list));
        for (User user1 : list) {
            redisTemplate.opsForList().leftPush("driver",JSONObject.toJSONString(user1));
        }

        return list;
    }

    /**
     * 查询用户
     * @param
     * @return
     */

//    @Override
//    public List<OrderResponse> userOrder() {
//        List<OrderResponse> list = dispatchMapper.userOrder();
//
//        for (OrderResponse response : list) {
//            redisTemplate.opsForList().leftPush("userOrder",JSONObject.toJSONString(response));
//        }
//        return list;
//    }

    /**
     * 派单
     *   先从用户表和司机表中拿到数据然后存到redis中，
     * @param orderReceiving
     */

//    @Override
//    public void melody(OrderReceiving orderReceiving) {
//        String a = "asd";
//        redisTemplate.opsForHash().put(a,1,a);
//        redisTemplate.opsForHash().get(a,1);
//
//
//        dispatchMapper.melody(orderReceiving);
//    }
//
//    @Override
//    public List<OrderReceiving> ReceivingList(OrderReceiving orderReceiving) {
//        return dispatchMapper.ReceivingList(orderReceiving);
//    }



}
